<template>
    <div>
        <div class="wrap">
            <input type="text" v-model="nickname">
        </div>
        <div class="submit">
            <mt-button size="small" type="primary" @click="submit">提交</mt-button>
        </div>
    </div>
</template>
<script>
    import { Button } from 'mint-ui';
    Vue.component(Button.name, Button);
    import {pageConfig} from '@/config';
    export default {
        name: 'login',
        data(){
            return {
                nickname: '',
            }
        },
        created: function () {
            if (!this.$user.is_login()) {
                this.$user.jumpLogin();
            } else {
                let userinfo = this.$user.getUinfo();
                this.nickname = userinfo.nickname;
            }
        },
        methods: {
            submit() {
                if (this.nickname === '') {
                    this.$toast('昵称不能为空');
                    return;
                }
                this.$http.$ajax('profile', pageConfig.public, {
                    nickname: this.nickname,
                }, {loading: '修改中...', success:(res)=> {
                    this.$toast('修改成功');
                    this.$user.setNickname(this.nickname);
                    this.$router.go(-1);
                }});
            }
        },
        computed: {

        }
    }
</script>
<style scoped>
    .wrap{
        margin: 0 auto;
        width: 80%;
        margin-top: 100px;
        border-bottom: 4px solid #858484;
        padding-bottom: 29px;
    }
    .wrap input{
        border: none;
        background: none;
        outline: none;
    }
    /deep/ .mint-button--primary {
        background-color: #6A74F6;
        width: 260px;
    }
    .submit{
        margin-left: -88px;
        margin-top: 225px;
        color: #ffffff;
        font-size: 32px;
        display: flex;
        justify-content: center;
    }
</style>
